<?php
/**
 * @version     1.0.1
 * @package     com_ganeshavereadores
 * @copyright  	
 * @license     
 * @author      Jorge Eduardo
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.keepalive');



?>


<div class="container  audiencia">

<?php
	$obj = null;
		foreach ($this->items as $item) :
			$obj = $item;
		endforeach;
		
	?>
	<h3>Atividade Legislativa</h3>
	
	<div id="menuinterno"></div>
	
	
	
	<div class="content">
		<h4 class="title">Audiências Públicas</h4>
		
		
		
		<p>No campo "Requerimento"  use "." e "/" e apenas dois caracteres para o ano. Ex. 1.746/13</p>
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
	<?php if ($this->params->get('show_headings') || $this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?>
	<fieldset >
		<?php if ($this->params->get('filter_field') != 'hide') :?>		
		<table>
		<tr>
			<td>Busca por palavra-chave</td>
			<td>Data</td>
			<td>Requerimento</div>
		</tr>
		<tr>
			<td>				
				<input type="text" name="filter-titulo" id="filter-titulo" value="<?php echo $this->escape($this->state->get('filter.titulo')); ?>" class="inputbox title"   />
			</td>
			<td>
				<input type="text" name="filter-data" id="filter-data" value="<?php echo $this->state->get('filter.data'); ?>" class="inputbox"   placeholder="Formato: dd/mm/aaaa" />
			</td>
			<td>
				<input type="text" name="filter-requerimento" id="filter-requerimento" value="<?php echo $this->state->get('filter.requerimento'); ?>" class="inputbox"   />
			</td>
		</tr>	
		<tr>
			<td></td>
			<td></td>
			<td align="right"><a style="float:right" href="javascript:void(0)" onclick="document.adminForm.submit();" title="Pesquisar"><img src="<?php echo JUri::base() ?>templates/cmmacae/img/btnPesquisar.png" /></a></td>
		</tr>
	
				
		</table>
		
		<?php endif; ?>
		

		<input type="hidden" name="filter_order" value="" />
		<input type="hidden" name="filter_order_Dir" value="" />
		<input type="hidden" id="limitstart" name="limitstart" value="" />
		<input type="hidden" name="task" value="" />
	</fieldset>
	<?php endif; 
	
	
	?>
</form>
		
		<ul class="t">
		
		<?php foreach ($this->items as $item) : ?>		         
			<li>
				<a href="<?php echo JRoute::_('index.php?option=com_audiencias&view=audiencia&id=' . (int)$item->id); ?>" title="<?php echo $item->titulo;?>"><?php echo $item->titulo; ?> </a>
				 <p><?php 
				 $data = $item->created;
				 echo getDateMyFormat($data);?> </p>
				 <p>Veja detalhes do Requerimento N&#186; <?php echo $item->requerimento;?>
			</li>
	
		<?php endforeach; ?>		
		
		<?php
		if(empty($this->items))
			echo "Nenhum item encontrado.";
		?>
		</ul>
	</div>
	
	

<?php // Add pagination links ?>
<?php if (!empty($this->items)) : ?>
	<?php if (($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2)) && ($this->pagination->pagesTotal > 1)) : ?>
	<div class="pagination">
		
		<div class="btnback">
			<a href="javascript:window.history.back()" title="Voltar à página anterior" ><img src="<?php echo JUri::base() ?>templates/cmmacae/img/btnBack.jpg" /></a>
		</div>
		
		<div class="pag">
		<?php if ($this->params->def('show_pagination_results', 1)) : ?>
			<p class="counter pull-right">
				<?php echo $this->pagination->getPagesCounter(); ?> - 
			</p>
		<?php endif; ?>
		<?php echo $this->pagination->getPagesLinks(); ?>
		</div>
	</div>
	<?php endif; ?>

<?php  endif; ?>


</div>

<?php


function getDateMyFormat($value){
	$dia = date("d", strtotime($value));
	$ano = date("Y", strtotime($value));
	$mes = date("m", strtotime($value));
	
	return $dia."/".$mes."/".$ano;
}
?>